*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*
* Diehl/Wolter: “ATTITUDES ABOUT CONTAINMENT MEASURES DURING
*                THE 2020/2021 CORONAVIRUS PANDEMIC: 
*                SELF-INTEREST, OR BROADER POLITICAL ORIENTATIONS?"
*
* Do-File for descriptive data analysis
*
* This version: 20210602
*
* Author: Felix Wolter, felix.wolter@uni-konstanz.de
*
*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

*Check: Fraction of respondents participating in both waves
tab sample

*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*Figure 2: Opposition against containment measures
reg openkitas5 i.time##i.east [pweight=persweight] 
margins, at(time=(0 1) east=(0 1)) post
estimates store opkitas

reg openschools5 i.time##i.east [pweight=persweight] 
margins, at(time=(0 1) east=(0 1)) post
estimates store opschools

reg openrestau5 i.time##i.east [pweight=persweight] 
margins, at(time=(0 1) east=(0 1)) post
estimates store oprestau

reg opencontact5 i.time##i.east [pweight=persweight] 
margins, at(time=(0 1) east=(0 1)) post
estimates store opcontact

reg openborders5 i.time##i.east [pweight=persweight] 
margins, at(time=(0 1) east=(0 1)) post
estimates store opborders

reg openevents5 i.time##i.east [pweight=persweight] 
margins, at(time=(0 1) east=(0 1)) post
estimates store opevents

coefplot (opkitas, msymb(O) mcolor(green*1.1) ciopts(lcolor(green*1.1))) ///
   (opschools, msymb(X) mcolor(gs12) ciopts(lcolor(gs12))) ///
   (oprestau, msymb(T) mcolor(blue) ciopts(lcolor(blue))) ///
   (opcontact, msymb(S) mcolor(red*1.5) ciopts(lcolor(red*1.5)) ) ///
   (opborders, msymb(D) mcolor(yellow*1.8) ciopts(lcolor(yellow*1.8)) ) ///
   opevents, msymb(+) mcolor(black) ciopts(lcolor(black))  /// 
   coeflabels(1._at = "May 2020, West" ///
              2._at = "May 2020, East" ///
			  3._at = "November 2020, West" ///
			  4._at = "November 2020, East", labsize(3)) ///
   graphregion(fcolor(gs15)) ///
   xlabel(1(1)5, labsize(2.5)) ///
   xline(1(.5)5, lcolor(gs12) lwidth(vthin)) ///
   legend(order(2 "Daycare" 4 "Schools" 6 "Restaurants/bars" ///
                8 "Contacts" 10 "Borders" 12 "Events") rows(2))


*Percentage values of opposition
bysort time: sum open*dum [aweight=persweight]

*Check: Correlations between subdimensions
bysort time: pwcorr openkitas5-openevents5 [aweight=persweight], sig


*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*Figure 3: Individual threats by region and time
reg idtecon i.time##i.east [pweight=persweight] 
margins, at(time=(0 1) east=(0 1)) post
estimates store idtecon

reg idtfamily i.time##i.east [pweight=persweight] 
margins, at(time=(0 1) east=(0 1)) post
estimates store idtfamily

logit childrenathome i.time##i.east [pweight=persweight] 
margins, at(time=(0 1) east=(0 1)) post
estimates store childrenathome

logit incloss i.time##i.east [pweight=persweight] 
margins, at(time=(0 1) east=(0 1)) post
estimates store incloss

logit riskgroup01 i.time##i.east [pweight=persweight] 
margins, at(time=(0 1) east=(0 1)) post
estimates store riskgroup01

logit old i.time##i.east [pweight=persweight] 
margins, at(time=(0 1) east=(0 1)) post
estimates store old

*Version 1 horizontally
coefplot (idtecon, msymb(O) mcolor(red*1.5) ciopts(lcolor(red*1.5)))  ///
   idtfamily, msymb(X) mcolor(blue) ciopts(lcolor(blue))  ///
   coeflabels(1._at = "May 2020, West" ///
              2._at = "May 2020, East" ///
			  3._at = "November 2020, West" ///
			  4._at = "November 2020, East", labsize(3.5)) ///
   title("Continuous variables", size(4.5) color(black)) ///
   graphregion(fcolor(gs15)) ///
   xlabel(2(.5)3, labsize(2.5)) ///
   xline(2(.2)3, lcolor(gs12) lwidth(vthin))  ///
   legend(order(2 "Indiv. threat economic" 4 "Indiv. threat family") rows(2)) ///
   saving(figure2a.gph, replace)


coefplot (childrenathome, msymb(T) mcolor(green*1.1) ciopts(lcolor(green*1.1))) ///
   (incloss, msymb(S) mcolor(black) ciopts(lcolor(black))) ///
   (riskgroup01, msymb(+) mcolor(yellow*1.8) ciopts(lcolor(yellow*1.8)))  ///
   old, msymb(D) mcolor(gs12) ciopts(lcolor(gs12))  ///
   coeflabels(, nolabels) ///
   title("Binary variables", size(4.5) color(black)) ///
   graphregion(fcolor(gs15)) ///
   xlabel(0(.1).5, labsize(2.5)) ///
   xline(0(.1).5, lcolor(gs12) lwidth(vthin))  ///
   legend(order(2 "Children at home" 4 "Income loss" 6 "Covid-19 at-risk group" ///
                8 "Age >70") rows(2)) ///
   saving(figure2b.gph, replace)
   
graph combine "figure2a" "figure2b"



*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*Table 2

bysort time east: sum sttecon [aweight=persweight]
bysort time: sum sttecon [aweight=persweight]

bysort time east: sum sttfamily [aweight=persweight]
bysort time: sum sttfamily [aweight=persweight]

bysort time east: sum doubtstate [aweight=persweight]
bysort time: sum doubtstate [aweight=persweight]

bysort time east: sum protransfer [aweight=persweight]
bysort time: sum protransfer [aweight=persweight]

bysort time east: tab leftrightcat [iweight=persweight]
bysort time: tab leftrightcat [iweight=persweight]

bysort time: tab east [iweight=persweight]

bysort time east: sum gentrust [aweight=persweight]
bysort time: sum gentrust [aweight=persweight]

bysort time east: tab female [iweight=persweight]
bysort time: tab female [iweight=persweight]

bysort time east: sum educyr [aweight=persweight]
bysort time: sum educyr [aweight=persweight]

bysort time east: sum kr_inz_rate10 [aweight=persweight]
bysort time: sum kr_inz_rate10 [aweight=persweight]

bysort time east: sum kr_tod_rate10 [aweight=persweight]
bysort time: sum kr_tod_rate10 [aweight=persweight]




*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*Table S1 (supplement): Opposition against confinement measures
bysort time east: reg openkitas5 [pweight=persweight] 
bysort time: reg openkitas5 [pweight=persweight] 

bysort time east: reg openschools5 [pweight=persweight] 
bysort time: reg openschools5 [pweight=persweight] 

bysort time east: reg openrestau5 [pweight=persweight] 
bysort time: reg openrestau5 [pweight=persweight] 

bysort time east: reg opencontact5 [pweight=persweight] 
bysort time: reg opencontact5 [pweight=persweight] 

bysort time east: reg openborders5 [pweight=persweight] 
bysort time: reg openborders5 [pweight=persweight] 


*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*Table S2 (supplement): Descriptive analysis: self-interest indicators (figure 3 from main article)

bysort time east: reg idtecon [pweight=persweight] 
bysort time: reg idtecon [pweight=persweight] 

bysort time east: reg incloss [pweight=persweight] 
bysort time: reg incloss [pweight=persweight] 

bysort time east: reg idtfamily [pweight=persweight] 
bysort time: reg idtfamily [pweight=persweight] 

bysort time east: reg childrenathome [pweight=persweight] 
bysort time: reg childrenathome [pweight=persweight] 

bysort time east: reg riskgroup01 [pweight=persweight] 
bysort time: reg riskgroup01 [pweight=persweight] 

bysort time east: reg old [pweight=persweight] 
bysort time: reg old [pweight=persweight] 



*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*Table S3 (supplement): Descriptive analysis: Sociotropic threat, political orientations, infection rates and control variables 

bysort time east: reg sttecon [pweight=persweight] 
bysort time: reg sttecon [pweight=persweight] 

bysort time east: reg sttfamily [pweight=persweight] 
bysort time: reg sttfamily [pweight=persweight] 

bysort time east: reg doubtstate [pweight=persweight] 
bysort time: reg doubtstate [pweight=persweight] 

bysort time east: reg protransfer [pweight=persweight] 
bysort time: reg protransfer [pweight=persweight] 

mlogit leftrightcat [pweight=persweight] if time==0 & east==0 
margins
mlogit leftrightcat [pweight=persweight] if time==0 & east==1 
margins
mlogit leftrightcat [pweight=persweight] if time==1 & east==0 
margins
mlogit leftrightcat [pweight=persweight] if time==1 & east==1 
margins
mlogit leftrightcat [pweight=persweight] if time==0 
margins
mlogit leftrightcat [pweight=persweight] if time==1 
margins

bysort time: reg east [pweight=persweight] 

bysort time east: reg gentrust [pweight=persweight] 
bysort time: reg gentrust [pweight=persweight] 

bysort time east: reg female [pweight=persweight] 
bysort time: reg female [pweight=persweight] 

bysort time east: reg educyr [pweight=persweight] 
bysort time: reg educyr [pweight=persweight] 

bysort time east: reg kr_inz_rate10 [pweight=persweight] 
bysort time: reg kr_inz_rate10 [pweight=persweight] 

bysort time east: reg kr_tod_rate10 [pweight=persweight] 
bysort time: reg kr_tod_rate10 [pweight=persweight] 

